package com.yby6.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.yby6.common.utils.context.IdWorker;
import com.yby6.system.mapper.SysLogMapper;
import com.yby6.system.domain.SysLog;
import com.yby6.system.service.SysLogService;

import java.util.List;

/**
 * ClassName: Loginfo
 * Description: 杨不易网站 :www.yangbuyi.top
 * date: 2021/5/12
 *
 * @author TeouBle
 * @author yangbuyi
 * @since JDK 1.8
 **/

@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {

    @Resource
    private SysLogMapper sysLogMapper;

    @Resource
    private IdWorker idWorker;

    @Override
    public int insert (SysLog record) {
        record.setLogId(idWorker.nextId());
        return sysLogMapper.insert(record);
    }

    /**
     * 分页查询系统日志集合
     *
     * @param sysLog
     * @return
     */
    @Override
    public List<SysLog> getLogByPage (SysLog sysLog) {
        return this.sysLogMapper.getLogByPage(sysLog);
    }

    /**
     * 根据Id查询系统日志集合
     *
     * @param id
     * @return
     */
    @Override
    public SysLog getLogById (Long id) {
        return sysLogMapper.selectByPrimaryKey(id);
    }

    /**
     * 根据Id删除系统日志集合
     *
     * @param id
     * @return
     */
    @Override
    public int deleteById (Long[] id) {
        return sysLogMapper.deleteById(id);
    }

    /**
     * 清空全部日志
     * @return
     */
    @Override
    public int deleteAll () {
        return sysLogMapper.deleteAll();
    }
}

